package top.dimples.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean(value = "defaultApi")
    public Docket defaultApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("抽奖网前台API文档v1.0")
                        .description("# 抽奖网前台 RESTful APIs")
                        .contact(new Contact("Dimples_YJ","https://www.dimples.top","2890841438@qq.com"))
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("前台接口")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("top.dimples.controller.api"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("抽奖网后台API文档v1.0")
                        .description("# 抽奖网后台 RESTful APIs")
                        .contact(new Contact("Dimples_YJ","https://www.dimples.top","2890841438@qq.com"))
                        .version("1.0")
                        .build())
                .groupName("后台接口")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("top.dimples.controller.admin"))
                .paths(PathSelectors.any())
                .build();
    }


    @Bean(value = "defaultApi3")
    public Docket defaultApi3() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("抽奖网后台API文档v1.0")
                        .description("# 抽奖网后台 RESTful APIs")
                        .contact(new Contact("Dimples_YJ","https://www.dimples.top","2890841438@qq.com"))
                        .version("1.0")
                        .build())
                .groupName("公共接口")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("top.dimples.controller.common"))
                .paths(PathSelectors.any())
                .build();
    }

}